<template>
  <div>
    <MyHeader title="购物车" />
    <div class="main">
      <MyGoods v-for="obj in list" :key="obj.id" :gObj="obj" />
    </div>
    <MyFooter @changeAll="allFn" :arr="list" />
  </div>
</template>

<script>
import MyHeader from "./components/MyHeader";
import MyGoods from "./components/MyGoods";
import MyFooter from "./components/MyFooter";

import { mapState } from "vuex";
export default {
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
  created() {
    this.$store.dispatch("asyncSetGoodsList");
  },
  computed: {
    ...mapState({ list: "goodsList" })
  },
  methods: {
    allFn(bool) {
      this.list.forEach(obj => (obj.goods_state = bool));
    }
  }
};
</script>

<style scoped>
.main {
  padding-top: 45px;
  padding-bottom: 50px;
}
</style>
